/************************************************************************
                        ReplyData.h
ReplyData is a reply with data.
it inherits from class Reply.
it contains data in a semi table form, sorted by column names, and order of input.

*/
#ifndef REPLYDATA_H
#define REPLYDATA_H
#include "Reply.h"
#include <vector>
#include <map>
using namespace std;


typedef vector<string>Params;//a parameters column
struct Tcolumn//a parameeters column with some more info about it
{
public:
	int maxStringLen;//this holds the length of the longest string in Params.
					//a printing accessory
	Params data;
};
typedef map<string,Tcolumn> Recordset;//this is sorted by column name
typedef vector<string>ColumnHeaders;//this is sorted by entry order
/**
  * class ReplyData
  */
class ReplyData : public Reply
{
public:
		// Constructors/Destructors
		ReplyData(int type);//ctor creates an empty replydata with type=type
		ReplyData(int errNumber,string errDescription);
		//ctor creates a replydata, containing an error, and an error description
		virtual ~ReplyData ( );
		//get parameter by its column name  and row
		virtual string getParameter(string column,unsigned int row)const;
		//get parameter by its column number(order of input) and row
		virtual string getParameter(unsigned int column,unsigned int row)const;
		//add a parameter by column.if the column exist it is added at the end of the column.
		//if column does not exist it is created and data is pushed at its head.
		virtual void addParameter(string column,string data);
		//returns an error description  - used if created by ReplyData(int errNumber,string errDescription);
		//it is similar to getParameter("ErrorDescription",0)
		string getErrDescription();
		//friend ostream& operator<<(ostream& os, Reply  &rhs);
		void print_recordset();//basic prints 
		//returns the maximum length of a string in a column(print accessory)
		unsigned int getMaxStringLen(string column);
protected:
private:
	ReplyData(ReplyData const &replydata);
	ReplyData &operator=(const ReplyData &rhs);
	Recordset m_Recordset;//the data container
	ColumnHeaders m_columnheaders;//hash of the column names - sorted by order of entry
	unsigned int m_rowCount;//counter of rows in data table
};

#endif // REPLYDATA_H
